home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / VideoToolbox 96.06.15 / VideoToolboxSources / TrapAvailable.c < prev    next >
Text File  |  1995-07-27  |  860b  |  42 lines

  1. /*
  2. TrapAvailable.c
  3. From Apple. Simply include <Traps.h> in your program and call this routine to find
  4. out whether any particular trap is available.
  5. */
  6. #include "VideoToolbox.h"
  7. #ifndef __TRAPS__
  8.     #include <Traps.h>
  9. #endif
  10.  
  11. // these are for internal use only
  12. short NumToolboxTraps(void);        
  13. TrapType GetTrapType(short theTrap);
  14.     
  15. Boolean    TrapAvailable(short theTrap)
  16. {
  17.     TrapType tType;
  18.     
  19.     tType=GetTrapType(theTrap);
  20.     if(tType==ToolTrap){
  21.         theTrap &= 0x07FF;
  22.         if(theTrap>=NumToolboxTraps())theTrap=_Unimplemented;
  23.     }
  24.     return NGetTrapAddress(theTrap,tType) != NGetTrapAddress(_Unimplemented,ToolTrap);
  25. }
  26.  
  27. short NumToolboxTraps(void)
  28. {
  29.     if (NGetTrapAddress(_InitGraf,ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  30.         return 0x0200;
  31.     else return 0x0400;
  32. }
  33.  
  34.  
  35. TrapType GetTrapType(short theTrap)
  36. {
  37.     if((theTrap & 0x0800)>0) return ToolTrap;
  38.     else return OSTrap;
  39. }
  40.  
  41.  
  42.